<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<%@ include file="../common/tags.jsp" %>  
<%String path = request.getContextPath();%>
<form id="pagerForm" method="post" action="<%=path %>/favourable/listFavourable.action">
	<input type="hidden" name="pageRequest" value="1" />
	<input type="hidden" name="pageNum" value="${paginator.pageIndex}" />
	<input type="hidden" name="numPerPage" value="${paginator.pageSize}" />
</form>

<div class="pageHeader">
	<form onsubmit="return navTabSearch(this);" rel="pagerForm" action="<%=path %>/favourable/listFavourable.action" method="post">
	<div class="searchBar">
		<ul class="searchContent">
			<li>
				<label style="text-align: right;">优惠券：</label>
				<input name="favourableVO.favourableEntityId" value="${favourableVO.favourableEntityId}" type="hidden" class="param">
				<input style="cursor: pointer;float: left;" onclick="$('#favourableEntityList_a_btnLook').click();" name="favourableVO.favourableEntityName" value="<s:property value="favourableVO.favourableEntityName" />" class="param"/>
				<!--  <a class="btnLook" id="#favourableEntityList_a_btnLook" href="<%=path%>/favourableEntity/listFavourableEntity.action?searchType=favourable" lookupGroup="favourableVO">选择</a>-->
			</li>
			<li>
				<label style="text-align: right;">编码：</label>
				<input type="text" name="favourableVO.code"  value="<s:property value="favourableVO.code" />"/>
			</li>
			<li>
				<label style="text-align: right;">获得方式：</label> 
				<s:select name="favourableVO.gainManner" list="%{#{'':'请选择',0:'商家发放',1:'自主获得',2:'其他'}}" listKey="key" listValue="value"></s:select>
			</li>
		</ul>
		<ul class="searchContent">
			<li>
				<label style="text-align: right;">状态：</label> 
				<s:select name="favourableVO.state" list="%{#{'':'请选择',0:'可使用',1:'已使用',2:'已过期',3:'已作废'}}" listKey="key" listValue="value" ></s:select>
			</li>
			<li>
				<label style="text-align: right;">所属会员：</label> 
				<input type="text" name="favourableVO.userName" value="<s:property value="favourableVO.userName" />"/>
			</li>
			<c:if test="${SESSION_USER.customer != null}">
				<li>
					<input name="favourableVO.customerId" value="${SESSION_USER.customer.id}" type="hidden">
				</li>
			</c:if>
			<c:if test="${SESSION_USER.customer == null}">
				<li>
					<label style="text-align: right;">所属商家：</label>
					<input name="favourableVO.customerId" value="${SESSION_USER.customer.id}" type="hidden">
					<input name="favourableVO.customerName" onclick="$('#favourableList_a_btnLook').click();" style="cursor: pointer;float: left;" value="<s:property value="favourableVO.customerName" />"/>
					<!-- <a class="btnLook" id="favourableList_a_btnLook" href="<%=path %>/customer/listCustomer.action?searchType=favourableEntity" lookupGroup="favourableVO">选择</a> -->
				</li>
			</c:if>
		</ul>
		<ul class="searchContent">
			<li style="width:450px">
				<label style="text-align: right;">获得时间：</label>
				从<input type="text" name="favourableVO.gtgainTime" value='<s:date name='favourableVO.gtgainTime' format="yyyy-MM-dd HH:mm:ss"/>'  dateFmt="yyyy-MM-dd HH:mm:ss" class="date" readonly="false"/>
				到<input type="text" name="favourableVO.ltgainTime" value='<s:date name='favourableVO.ltgainTime' format="yyyy-MM-dd HH:mm:ss"/>'  dateFmt="yyyy-MM-dd HH:mm:ss" class="date" readonly="false"/>
			</li>
			<li style="width:450px">
				<label style="text-align: right;">使用时间：</label>
				从<input type="text" name="favourableVO.gtuseTime" value='<s:date name='favourableVO.gtuseTime' format="yyyy-MM-dd HH:mm:ss"/>'  dateFmt="yyyy-MM-dd HH:mm:ss" class="date" readonly="false"/>
				到<input type="text" name="favourableVO.ltuseTime" value='<s:date name='favourableVO.ltuseTime' format="yyyy-MM-dd HH:mm:ss"/>'  dateFmt="yyyy-MM-dd HH:mm:ss" class="date" readonly="false"/>
			</li>
		</ul>
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">查询</button></div></div></li>
			</ul>
		</div>
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			<shiro:hasPermission name="deleteFavourable">
			<li><a title="确实要删除这些记录吗?" target="selectedTodo" rel="ids" postType="string" href="<%=path %>/favourable/deleteFavourable.action" class="delete"><span>删除</span></a></li>
			</shiro:hasPermission>
			<shiro:hasPermission name="editFavourable">
			<li><a class="edit" href="<%=path %>/favourable/editFavourable.action?favourableVO.id={sid_user}" target="navTab" warn="请选择一条记录"><span>修改</span></a></li>
			</shiro:hasPermission>
			<shiro:hasPermission name="saveFavourable">
			<li><a title="确实要使用这些优惠券吗?" rel="ids" class="edit" postType="string" href="<%=path %>/favourable/saveFavourable.action?act=use" target="selectedTodo" ><span>使用</span></a></li>
			</shiro:hasPermission>
		</ul>
	</div>
	<table class="table" width="1150" layoutH="189">
		<thead>
			<tr>
				<th width="30"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
				<th>优惠券</th>
				<th>会员名</th>
				<th>会员卡编码</th>
				<th>所属商家</th>
				<th>获得时间</th>
				<th>获得方式</th>
				<th>状态</th>
				<th>使用时间</th>
				<th>编码</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			<s:iterator value="favourableList" id="favourable" status="st">
				<tr target="sid_user" rel="<s:property value="id" />">
					<td><input name="ids" value="<s:property value="id" />" type="checkbox"></td>
             <td><s:property value="favourableEntity.name" /></td>	
             <td><s:property value="userName"/></td>
             <td><s:property value="memberCardCode" /></td>
             <td><s:property value="customerName"/></td>	
	<td><s:date name="gainTime" format="yyyy-MM-dd HH:mm:ss" /></td>
             <td> 
             <s:if test="%{#favourable.gainManner == 0}">商家发放</s:if>
             <s:if test="%{#favourable.gainManner == 1}">自主获得</s:if>
             <s:if test="%{#favourable.gainManner == 2}">其他</s:if>
             </td>
             <td>
             <s:if test="%{#favourable.state == 0}">可使用</s:if>
             <s:if test="%{#favourable.state == 1}">已使用</s:if>
             <s:if test="%{#favourable.state == 2}">已过期</s:if>
             <s:if test="%{#favourable.state == 3}">已作废</s:if>
             </td>
	<td><s:date name="useTime" format="yyyy-MM-dd HH:mm:ss" /></td>
             <td><s:property value="code" /></td>	
					<td>
						<shiro:hasPermission name="deleteFavourable">
						<a title="确实要删除这条记录吗?" target="ajaxTodo" href="<%=path %>/favourable/deleteFavourable.action?ids=<s:property value="id" />" class="btnDel">删除</a>
						</shiro:hasPermission>
						<shiro:hasPermission name="editFavourable">
						<a title="编辑" target="navTab" href="<%=path %>/favourable/editFavourable.action?favourableVO.id=<s:property value="id" />" class="btnEdit">编辑</a>
						</shiro:hasPermission>
						<a title="查看" target="navTab" href="<%=path %>/favourable/viewFavourable.action?favourableVO.id=<s:property value="id" />" class="btnView">查看</a>
					</td>
				</tr>
			</s:iterator>
		</tbody>
	</table>
	<div class="panelBar">
		<div class="pages">
				<span>显示</span>
				<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
					<option value="15" <c:if test="${paginator.pageSize==15}">selected='selected'</c:if> >15</option>
					<option value="30" <c:if test="${paginator.pageSize==30}">selected='selected'</c:if> >30</option>
					<option value="50" <c:if test="${paginator.pageSize==50}">selected='selected'</c:if> >50</option>
					<option value="100" <c:if test="${paginator.pageSize==100}">selected='selected'</c:if> >100</option>
					<option value="200" <c:if test="${paginator.pageSize==200}">selected='selected'</c:if> >200</option>
				</select>
				<span>条，共${paginator.totalCount}条</span>
			</div>
			<div class="pagination" targetType="navTab" totalCount="${paginator.totalCount}" 
				numPerPage="${paginator.pageSize}" pageNumShown="10" currentPage="${paginator.pageIndex}"></div>

	</div>
</div>